#include <stdio.h>
#include <stdlib.h>

#include "cppTutorGlobals.h"
#include "cppTutor_C_MemoryManagement.h"

memoryManagement *mem; //typedef struct memoryManagement

int* pnArray;

void GetMemory ()
{
    int nSize;
    int i = 0;
    printf ("How many elements you want to store\n");
    scanf  ("%d", &nSize);
#ifdef MALLOC
    pnArray = (int*) malloc (nSize * sizeof (int));
    mem     = (memoryManagement*) malloc (sizeof (mem));
#endif // MALLOC

#ifdef CALLOC
    pnArray = (int*) calloc (nSize, sizeof (int));
    mem     = (memoryManagement*) calloc (nSize, sizeof (mem));
#endif // CALLOC

#ifdef REALLOC
    mem     = (memoryManagement*) realloc (nSize+10, sizeof (mem));
#endif //REALLOC
    printf ("checking default memory value assigned\n");
    for (; i<nSize; i++)
    {
        printf ("%d\n", pnArray [i]);
    }

    mem->cArray = 'A';
    mem->nArray = 10;

    free (pnArray);
    //free (mem);
}
